Add support for PredefinedFilters for QueryChannels#6426
Draft
VelikovPetar wants to merge 3 commits intov6from
Draft
Add support for PredefinedFilters for QueryChannels#6426VelikovPetar wants to merge 3 commits intov6from
PredefinedFilters for QueryChannels#6426VelikovPetar wants to merge 3 commits intov6from
Conversation
Contributor
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
Contributor
|
DB Entities have been updated. Do we need to upgrade DB Version? |
Contributor
SDK Size Comparison 📏
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Goal
Add support for server-side
PredefinedFilterstoQueryChannels. Apps can now run a channel query by referencing a filter/sort registered on the backend (by name, plus interpolation values) instead of building theFilterObject/QuerySorteron the client. This lets product/backend tweak filtering rules without an app release.You can check / update / create the predefined filters for the app "Stream Mobile SDK / Stream SDK - Android" - in the "Predefined Filters" section in the Beta Dashboard
Implementation
Public API
QueryChannelsRequestgainspredefinedFilter: String?,filterValues: Map<String, Any>?,sortValues: Map<String, Any>?. WhenpredefinedFilteris set, the client-sidefilter/querySortare ignored by the backend.QueryChannelsResultis a new wrapper aroundChatApi.queryChannelsthat exposes bothchannelsand the backend-resolvedPredefinedFilter(parsedname+FilterObject+QuerySorter<Channel>).ChannelListViewModel(Compose) andChannelListViewModel(UI Components) get a new constructor /ChannelListViewModelFactoryoverload takingpredefinedFilterName,filterValues,sortValues. In predefined mode,setFilters/setQuerySortare no-ops; channel search still narrows the displayed list.State / offline architecture
QueryChannelsIdentifiersealed type (Standard/Predefined) is the canonical key used byLogicRegistry,StateRegistry, the listener, and the offline repository. AQueryChannelsRequest/QueryChannelsSpecresolves to one or the other depending on whetherpredefinedFilteris present.QueryChannelsSpeckeeps its existing(filter, querySort)constructor (so JVM signatures stay stable) and addspredefinedFilterName/predefinedFilterValues/predefinedSortValuesasvars. For predefined queries, those three form the row's stable identity;filter/querySortcarry the currently resolved values.QueryChannelsMutableStatestarts predefined queries with placeholder filter/sort and applies the resolved spec viaapplyResolvedSpec(...)once the backend response arrives (or the row is rehydrated from disk).ChannelListViewModel.QueryMode(StandardvsPredefined) drives the two flows — pagination, refresh, search, and filter-flow wiring branch on it.Persistence
QueryChannelsEntitygainspredefinedFilterName/predefinedFilterValues/predefinedSortValues.QueryChannelsRepository.selectBy(identifier)replaces the previous filter-based lookup.104(destructive migration, in line with the rest of the SDK).Wire format
FilterDomainMappingnow supports a full round-trip (DTO ↔ domain) so the resolved predefined filter coming back from the server can be parsed into aFilterObjectand stored.Testing
QueryChannelsIdentifierderivation,MoshiChatApi,FilterDomainMapping(round trip),QuerySortByFieldround trip,DatabaseQueryChannelsRepository,QueryChannelsLogic/QueryChannelsDatabaseLogic/QueryChannelsListenerState,QueryChannelsMutableState,LogicRegistry, and bothChannelListViewModels.android_sample_filterso the feature can be exercised end-to-end on device.